﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PmSoft.Cache.Abstractions;
using PmSoft.Cache.Redis;
using PmSoft.Core;
using PmSoft.Data.Abstractions;
using PmSoft.Data.SqlSugar;

namespace Demo.Application;

public static class ServiceCollectionExtensions
{
	public static IServiceCollection AddDemoApplication(this IServiceCollection services, IConfiguration configuration)
	{
		services.AddCore(configuration);
		services.AddDefaultCache(configuration);
		services.AddRedisCache(configuration);
		services.AddSingleton<IDbNamesResolver, SnakeNamesResolver>();
		services.AddSqlSugar(builder =>
		{
			builder.AddConfig(configuration.GetConnectionString("App")!, SqlSugar.DbType.MySql, true, "App");

		});
		//services.AddPetaPoco();
		return services;
	}
}
